package work.lrl.customer_unbinding;

import cn.hutool.core.io.FileUtil;
import cn.hutool.json.JSONArray;
import lombok.SneakyThrows;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.List;

/**
 * @author Gong.Yang
 */
public class DemoLogProcess {
    static private final String logFilePath = "E:\\work-records\\l陆叶\\le-会员解绑\\2023-08-11Out\\异常日志.log";
    static private final String outFilePath = "E:\\work-records\\l陆叶\\le-会员解绑\\2023-08-11Out\\empty.json";

    @SneakyThrows
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(logFilePath)));
        JSONArray jsonArray = new JSONArray();
        String line = null;
        while ((line = reader.readLine()) != null) {
            String tag = "【会员解绑】通过手机号查询用户异常 ";
            if (!line.contains(tag)) {
                continue;
            }
            String[] split = line.split(tag);
            String data = split[1];
            jsonArray.add(data);
        }

        FileUtil.writeString(jsonArray.toString(), outFilePath, Charset.defaultCharset());
    }
}
